﻿package core.ui
{
    import flash.text.*;
    import flash.utils.*;

    public class Hover extends TextField
    {
        var ed:Tuyitu;
        var id:uint;
        var lastshow:uint = 0;

        public function Hover(param1:Tuyitu)
        {
            this.ed = param1;
            this.defaultTextFormat = new TextFormat("Verdana, Helvetica, San-serif", 10, 0);
            this.background = true;
            this.backgroundColor = 16056216;
            this.selectable = false;
            this.border = true;
            this.borderColor = 0;
            this.height = 16;
            this.autoSize = TextFieldAutoSize.LEFT;
            this.visible = false;
            return;
        }// end function

        public function Set(U:String) : void
        {
            this.text = U.RM(U);
            this.id = setTimeout(this.Show, this.lastshow + 800 > getTimer() ? (100) : (1500));
            return;
        }// end function

        public function Hide(... args) : void
        {
            if (this.visible)
            {
                this.lastshow = getTimer();
                this.visible = false;
            }
            clearTimeout(this.id);
            return;
        }// end function

        private function Show() : void
        {
            this.visible = true;
            this.x = this.ed.mouseX + this.width + 10 > stage.stageWidth ? (stage.stageWidth - 10 - this.width) : (this.ed.mouseX + 5);
            this.y = this.ed.mouseY + 20;
            return;
        }// end function

    }
}
